//
//  ZCOrderCheckInputMsgCell.m
//  ZCJZ
//
//  Created by sujeking on 2019/2/27.
//  Copyright © 2019年 jeking. All rights reserved.
//

#import "ZCOrderCheckInputMsgCell.h"

@interface ZCOrderCheckInputMsgCell()<UITextViewDelegate>

@property (weak, nonatomic) IBOutlet UITextView *textview;
@property (nonatomic, strong) UILabel *placeHolderLabel;
@end

@implementation ZCOrderCheckInputMsgCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    [self setupSubViews];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setFrame:(CGRect)frame{
    frame.origin.x += 10;
//    frame.origin.y += 10;
//    frame.size.height -= 10;
    frame.size.width -= 20;
    [super setFrame:frame];
}


- (void)setupSubViews {
    self.textview.text = nil;
    
    UILabel *placeHolderLabel = [[UILabel alloc] init];
    placeHolderLabel.text = @"请输入内容";
    placeHolderLabel.numberOfLines = 0;
    placeHolderLabel.textColor = [UIColor lightGrayColor];
    [placeHolderLabel sizeToFit];
    self.placeHolderLabel = placeHolderLabel;
    [self.textview addSubview:placeHolderLabel];
    self.textview.delegate = self;
    // same font
    self.textview.font = [UIFont systemFontOfSize:14.f];
    placeHolderLabel.font = self.textview.font;
    [self.textview setValue:placeHolderLabel forKey:@"_placeholderLabel"];
}

- (void)setPlaceholder:(NSString *)placeholder {
    _placeholder = placeholder;
    self.placeHolderLabel.text = placeholder;
}

// MARK: - UITextViewDelegate

- (void)textViewDidEndEditing:(UITextView *)textView {
    if (self.endEditCallback) {
        self.endEditCallback(textView.text);
    }
}

- (void)setContentStr:(NSString *)contentStr {
    _contentStr = contentStr;
    self.textview.text = contentStr;
}

@end
